package com.kun.demo01;


import org.junit.Test;

//测试静态代理--用户/代理/接口
public class StaticProxy {

    //接口--所做事情
    interface Marry{
        void happyMarry();
    }

    class Proxy implements Marry{

        private User user;

        public Proxy(User user){
            this.user = user;
        }

        public void happyMarry() {
            before();
            this.user.happyMarry();
            after();
        }

        public void before(){
            System.out.println("before Marry");
        }

        public void after(){
            System.out.println("after Marry");
        }
    }

    //用户
    class User implements Marry{
        public void happyMarry() {
            System.out.println("Happy Marry!");
        }
    }


    @Test
    public void test() {
        new Proxy(new User()).happyMarry();
    }
}
